﻿Option Strict On

Imports System.Text
Imports System.Globalization
Imports System.Net.Sockets

Namespace Proxy
    Friend NotInheritable Class Utils

        Private Sub New()
        End Sub

        Friend Shared Function GetHost(ByVal client As TcpClient) As String
            If client Is Nothing Then
                Throw New ArgumentNullException("client")
            End If

            Dim host As String = ""
            Try
                host = DirectCast(client.Client.RemoteEndPoint, System.Net.IPEndPoint).Address.ToString()
            Catch
            End Try

            Return host
        End Function

        Friend Shared Function GetPort(ByVal client As TcpClient) As String
            If client Is Nothing Then
                Throw New ArgumentNullException("client")
            End If

            Dim port As String = ""
            Try
                port = DirectCast(client.Client.RemoteEndPoint, System.Net.IPEndPoint).Port.ToString(CultureInfo.InvariantCulture)
            Catch
            End Try

            Return port
        End Function

    End Class
End Namespace